<?php
/**
 * 
 * @author Youssef Driouach
 *
 * 9 nov. 2012
 */
class Application_Model_Address
{
	protected $_addressId;
	protected $_text;
	protected $_zipCode;
	protected $_city;
	protected $_latitude;
	protected $_longitude;
	protected $_admin_area_lvl1;
	protected $_admin_area_lvl2;
	protected $_country;
// 	protected $_locTree;
	
	public function __construct(array $options = null)
	{
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value)
	{
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid Address property');
		}
		$this->$method($value);
	}
	
	public function __get($name)
	{
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid address property');
		}
		return $this->$method();
	}
	
	public function setOptions(array $options)
	{
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	
	
	

	/**
	 * @return the $_addressId
	 */
	public function getAddressId() {
		return $this->_addressId;
	}

	/**
	 * @param field_type $_addressId
	 */
	public function setAddressId($_addressId) {
		$this->_addressId = $_addressId;
	}

	public function setText($text)
	{
		$this->_text = (string) $text;
		return $this;
	}
	
	public function getText()
	{
		return $this->_text;
	}
	
	public function setZipCode($zipCode)
	{
		$this->_zipCode = (string) $zipCode;
		return $this;
	}
	
	public function getZipCode()
	{
		return $this->_zipCode;
	}
	
	public function setCity($city)
	{
		$this->_city = (string) $city;
		return $this;
	}
	
	public function getCity()
	{
		return $this->_city;
	}
	public function setCountry($country)
	{
		$this->_country = (string) $country;
		return $this;
	}
	
	public function getCountry()
	{
		return $this->_country;
	}
// 	/**
// 	 * @return the $_locTree
// 	 */
// 	public function getLocTree() {
// 		return $this->_locTree;
// 	}

// 	/**
// 	 * @param field_type $_locTree
// 	 */
// 	public function setLocTree(Application_Model_LocTree $_locTree) {
// 		$this->_locTree = $_locTree;
// 	}

	/**
	 * @return the $_latitude
	 */
	public function getLatitude() {
		return $this->_latitude;
	}

	/**
	 * @return the $_longitude
	 */
	public function getLongitude() {
		return $this->_longitude;
	}

	/**
	 * @return the $_admin_area_lvl1
	 */
	public function getAdmin_area_lvl1() {
		return $this->_admin_area_lvl1;
	}

	/**
	 * @return the $_admin_area_lvl2
	 */
	public function getAdmin_area_lvl2() {
		return $this->_admin_area_lvl2;
	}

	/**
	 * @param field_type $_latitude
	 */
	public function setLatitude($_latitude) {
		$this->_latitude = $_latitude;
	}

	/**
	 * @param field_type $_longitude
	 */
	public function setLongitude($_longitude) {
		$this->_longitude = $_longitude;
	}

	/**
	 * @param field_type $_admin_area_lvl1
	 */
	public function setAdmin_area_lvl1($_admin_area_lvl1) {
		$this->_admin_area_lvl1 = $_admin_area_lvl1;
	}

	/**
	 * @param field_type $_admin_area_lvl2
	 */
	public function setAdmin_area_lvl2($_admin_area_lvl2) {
		$this->_admin_area_lvl2 = $_admin_area_lvl2;
	}

}